package gameconfig

import (
	"context"
	v1 "goGameWebServer/api/game_config/v1"
	"goGameWebServer/internal/controller"
	"goGameWebServer/internal/defines/cerror"
	"goGameWebServer/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

func (c *GameConfigControllerV1) GameConfigQuery(ctx context.Context, req *v1.GameConfigQueryReq) (
	res *v1.GameConfigQueryRes, err error) {
	configs, e := entity.FormatConfigsFromDB(ctx, 0)
	if e != nil {
		controller.BackResponseError(g.RequestFromCtx(ctx), cerror.GAME_CONFIG_QUERY_ERROR,
			cerror.GetErrMsg(cerror.GAME_CONFIG_QUERY_ERROR))
		return
	}
	controller.BackResponseOK(g.RequestFromCtx(ctx), configs)
	return
}
